package JDBC_Test.Fruit.Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

import JDBC_Test.Fruit.Model.FruitInMedel;
import JDBC_Test.Fruit.*;

public class FruitInDao {
	Connection con = null;
	Statement st = null;
	PreparedStatement ps = null;

	/**
	 * 添加其他品种的水果
	 * 
	 * @param inMedel
	 * @throws SQLException
	 */
	public void insert(FruitInMedel inMedel) throws SQLException {
		// TODO Auto-generated method stub
		String sql = "insert into fruit_in (fruit_name,amount,in_price,date) values(?,?,?,?)";
		try {
			con = JDBCUtil.getConnection();
			ps = con.prepareStatement(sql);
			ps.setString(1, inMedel.getFruitName());
			ps.setInt(2, inMedel.getAmount());
			ps.setBigDecimal(3, inMedel.getInPrice());
			ps.setTimestamp(4, inMedel.getDate());
			ps.executeUpdate();

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		} finally {
			JDBCUtil.close(con, st, ps);

		}

	}

}
